Skip to content

Adjust d3 update to enable text mode animation #1011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 5, 2016
Merged

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Oct 5, 2016

cc @etpinard @cpsievert

This PR refactors text mode scatter just slightly to properly duck-type the node being translated as a transition. The text node itself remains an instantaneous update.

text-animation

@rreusser rreusser force-pushed the fix-text-animation branch from 785d46b to 4f3f0a6 Compare October 5, 2016 17:14
.each(function(d) {

// This just *has* to be totally custom becuase of SVG text positioning :(
// It's obviously copied from translatePoint; we just can't use that
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: technically I think maybe translatePoint would work. I'm not 100% certain how much work it is to recompute the positions a bunch, but it seems silly to do that for every tspan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha. That's not too bad. Thanks for the comment!

@rreusser
Copy link
Contributor Author

rreusser commented Oct 5, 2016

For reference, the challenge here was to position multiline text (= tspans) correctly since the precise sequence of events here is a little tricky. The solution was to recompute the positions an extra time, which I don't like but which I think is unavoidable.

ezgif-1116565138

@rreusser rreusser added bug something broken feature something new status: reviewable labels Oct 5, 2016
@etpinard etpinard added this to the v1.18.0 milestone Oct 5, 2016
.each(function(d) {

// This just *has* to be totally custom becuase of SVG text positioning :(
// It's obviously copied from translatePoint; we just can't use that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha. That's not too bad. Thanks for the comment!

@etpinard
Copy link
Contributor

etpinard commented Oct 5, 2016

💃 nicely done.

@rreusser
Copy link
Contributor Author

rreusser commented Oct 5, 2016

Turned out to be reasonably straightforward after messing around with it for three hours…

@rreusser rreusser merged commit 85dacd7 into master Oct 5, 2016
@rreusser rreusser deleted the fix-text-animation branch October 5, 2016 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants